package org.secangkirkopipanas.gxtcore.domain.dto;

import java.util.Date;

import net.sf.hibernate4gwt.pojo.java5.LazyPojo;

import org.secangkirkopipanas.gxtcore.domain.ISystemLog;

public class SystemLogDTO extends LazyPojo implements ISystemLog {

	private static final long serialVersionUID = 1L;

	public static final byte LEVEL_INFO = 1;
	public static final byte LEVEL_WARNING = 2;
	public static final byte LEVEL_ERROR = 3;

	private Long id;
	private Date date;
	private int level;
	private String appName;
	private String moduleName;
	private String userName;
	private String ipAddress;
	private String description;

	public SystemLogDTO() {
		super();
	}

	public SystemLogDTO(int level, String appName, String moduleName,
			String userName, String ipAddress, String description) {
		this(new Date(), level, appName, moduleName, userName, ipAddress,
				description);
	}

	public SystemLogDTO(Date date, int level, String appName,
			String moduleName, String userName, String ipAddress,
			String description) {
		super();
		this.date = date;
		this.level = level;
		this.appName = appName;
		this.moduleName = moduleName;
		this.userName = userName;
		this.ipAddress = ipAddress;
		this.description = description;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Date getDate() {
		return date;
	}

	public void setDate(Date date) {
		this.date = date;
	}

	public int getLevel() {
		return level;
	}

	public void setLevel(int level) {
		this.level = level;
	}

	public String getAppName() {
		return appName;
	}

	public void setAppName(String appName) {
		this.appName = appName;
	}

	public String getModuleName() {
		return moduleName;
	}

	public void setModuleName(String moduleName) {
		this.moduleName = moduleName;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getIpAddress() {
		return ipAddress;
	}

	public void setIpAddress(String ipAddress) {
		this.ipAddress = ipAddress;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String text) {
		this.description = text;
	}

	public String getLevelName() {
		String name = "";
		switch (level) {
		case LEVEL_INFO:
			name = "INFO";
			break;
		case LEVEL_WARNING:
			name = "WARNING";
			break;
		case LEVEL_ERROR:
			name = "ERROR";
			break;
		default:
			break;
		}
		return name;
	}

}
